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nzik/26hM0/QWeoANXqSjxoiWY+r5gyh
tr+WQ/8Fd4zq4Q==`
// 加密
export function RSAencrypt(pas) {
  var jse = new JsEncrypt({
    default_key_size: 2048 // 密钥位数
  })
  jse.setPublicKey(publicKey)
  console.log(jse.encrypt(pas))
  return jse.encrypt(pas.toString())
}

// 解密
export function RSAdencrypt(pas) {
  var jse = new JsEncrypt()
  //   jse.setPublicKey(publicKey)
  jse.setPrivateKey(privateKey)
  return jse.decrypt(pas)
}

export default {
  RSAencrypt, RSAdencrypt
}
